﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
   
/// <summary>
    /// SysBasicCodeName
    /// </summary>
    public partial class SysBasicCodeName
    {
        private readonly ElingOA6_DSJCJ.DAL.SysBasicCodeName dal = new ElingOA6_DSJCJ.DAL.SysBasicCodeName();
        public SysBasicCodeName()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="fCodeClsNo"></param>
        /// <param name="fEntityNo"></param>
        /// <param name="fCodeNo"></param>
        /// <returns></returns>
        public bool Exists(string fCodeClsNo, string fEntityNo, string fCodeNo)
        {
            return dal.Exists(fCodeClsNo, fEntityNo, fCodeNo);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model"></param>
        public void Add(ElingOA6_DSJCJ.Model.SysBasicCodeName model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Update(ElingOA6_DSJCJ.Model.SysBasicCodeName model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <param name="fCodeClsNo"></param>
        /// <param name="fEntityNo"></param>
        /// <param name="fCodeNo"></param>
        /// <returns></returns>
        public bool Delete(string fCodeClsNo, string fEntityNo, string fCodeNo)
        {

            return dal.Delete(fCodeClsNo, fEntityNo, fCodeNo);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="fCodeClsNo"></param>
        /// <param name="fEntityNo"></param>
        /// <param name="fCodeNo"></param>
        /// <returns></returns>
        public ElingOA6_DSJCJ.Model.SysBasicCodeName GetModel(string fCodeClsNo, string fEntityNo, string fCodeNo)
        {

            return dal.GetModel(fCodeClsNo, fEntityNo, fCodeNo);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>数据列表</returns>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        /// <param name="top"></param>
        /// <param name="strWhere"></param>
        /// <param name="filedOrder"></param>
        /// <returns>数据列表</returns>
        public DataSet GetList(int top, string strWhere, string filedOrder)
        {
            return dal.GetList(top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeName> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
       /// <param name="dt"></param>
       /// <returns></returns>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeName> DataTableToList(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.SysBasicCodeName> modelList = new List<ElingOA6_DSJCJ.Model.SysBasicCodeName>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.SysBasicCodeName model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ElingOA6_DSJCJ.Model.SysBasicCodeName();
                    model.FCodeClsNo = dt.Rows[n]["FCodeClsNo"].ToString();
                    model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    model.FCodeNo = dt.Rows[n]["FCodeNo"].ToString();
                    model.FCodeName = dt.Rows[n]["FCodeName"].ToString();
                    model.FDataType = dt.Rows[n]["FDataType"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
       /// <returns></returns>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        #endregion  Method


        #region 增加的方法

        /// <summary>
        /// 获取数据列表 部分字段 FCodeNo,FCodeName,FDataType 根据FDataType降序
        /// </summary>
        /// <param name="clsNo"></param>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeName> GetListByClsNo(string clsNo, string entityNo)
        {
            DataSet ds = dal.GetListByClsNo(clsNo, entityNo);
            return DataTableToListPart(ds.Tables[0]);
        }


        /// <summary>
        /// 获得数据列表 部分字段 FCodeNo,FCodeName,FDataType
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeName> DataTableToListPart(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.SysBasicCodeName> modelList = new List<ElingOA6_DSJCJ.Model.SysBasicCodeName>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.SysBasicCodeName model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ElingOA6_DSJCJ.Model.SysBasicCodeName();
                    model.FCodeNo = dt.Rows[n]["FCodeNo"].ToString();
                    model.FCodeName = dt.Rows[n]["FCodeName"].ToString();
                    model.FDataType = dt.Rows[n]["FDataType"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        #endregion



    }
}